// PowerManager.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "PowerManager.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPowerManager property page

IMPLEMENT_DYNCREATE(CPowerManager, CPropertyPage)

CPowerManager::CPowerManager() : CPropertyPage(CPowerManager::IDD)
{
	//{{AFX_DATA_INIT(CPowerManager)
	m_iPowerMode = -1;
	//}}AFX_DATA_INIT
}

CPowerManager::~CPowerManager()
{
}

void CPowerManager::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPowerManager)
	DDX_Radio(pDX, IDC_PowerMode, m_iPowerMode);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPowerManager, CPropertyPage)
	//{{AFX_MSG_MAP(CPowerManager)
	ON_BN_CLICKED(IDC_PowerMode, OnPowerMode)
	ON_BN_CLICKED(IDC_BatteryOptimize, OnBatteryOptimize)
	ON_BN_CLICKED(IDC_AutoSwitch, OnAutoSwitch)
	ON_BN_CLICKED(IDC_ManualSet, OnManualSet)
	ON_CBN_CLOSEUP(IDC_PMUpdateRate, OnCloseupPMUpdateRate)
	ON_BN_CLICKED(IDC_PMSet, OnPMSet)
	ON_BN_CLICKED(IDC_IntelligentSwitch, OnIntelligentSwitch)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPowerManager message handlers

BOOL CPowerManager::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	if (!m_PowerManager.Create(this))
		g_GlobalObj.UIWriteLog("m_PowerManager.Create Error");
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPowerManager::OnPowerMode() 
{
	if (!m_PowerManager.PowerModeChanged())
		g_GlobalObj.UIWriteLog("m_PowerManager.PowerModeChanged Error");

}

void CPowerManager::OnBatteryOptimize() 
{
	if (!m_PowerManager.PowerModeChanged())
		g_GlobalObj.UIWriteLog("m_PowerManager.PowerModeChanged Error");
	
}

void CPowerManager::OnAutoSwitch() 
{
	if (!m_PowerManager.PowerModeChanged())
		g_GlobalObj.UIWriteLog("m_PowerManager.PowerModeChanged Error");
	
}

void CPowerManager::OnIntelligentSwitch() 
{
	if (!m_PowerManager.PowerModeChanged())
		g_GlobalObj.UIWriteLog("m_PowerManager.PowerModeChanged Error");

}

void CPowerManager::OnManualSet() 
{
	if (!m_PowerManager.PowerModeChanged())
		g_GlobalObj.UIWriteLog("m_PowerManager.PowerModeChanged Error");	
}

void CPowerManager::OnCloseupPMUpdateRate() 
{
	if (!m_PowerManager.UpdateRateChanged())
		g_GlobalObj.UIWriteLog("m_PowerManager.UpdateRateChanged Error");	
	
}

BOOL CPowerManager::OnSetActive() 
{
	if(!m_PowerManager.UpdateUI())
		g_GlobalObj.UIWriteLog("m_PowerManager.UpdateUI Error");
	
	return CPropertyPage::OnSetActive();
}

BOOL CPowerManager::OnKillActive() 
{
/*	if(!m_PowerManager.UpdateMemberVariables())
		g_GlobalObj.UIWriteLog("m_PowerManager.UpdateMemberVariables Error");
*/	
	return CPropertyPage::OnKillActive();
}

void CPowerManager::OnPMSet() 
{
	if(!m_PowerManager.PMSet())
		g_GlobalObj.UIWriteLog("m_PowerManager.PMSet Error");	
}


